<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" v-model="Fname">
        <input type="text" v-model="Lname"><br>
        
        <button  @click="updata">修改</button>
        <button></button>
        {{add}}
        
    </div>
    <script>
        const vm = new Vue({
            el:"#app",
            data(){
                return {
                    Fname:'',
                    Lname:'',
                    yin:''
                }
            },
                
            computed:{
                add: {
                    // 当计算属性被读取的时候  就会调用get读取属性
                    get(){
                        console.log('get方法被调用');
                        return this.Fname.toUpperCase() + "-" + this.Lname.toUpperCase();
                    },
                    //当属性被设置的时候就会调用set方法 设置的值为value
                    set(value){
                        console.log('set被调用了',value);
                        [this.Fname,this.Lname] = value.split(' ')
                    }
                },
            },
            methods:{
                updata(){
                    this.add= 'xiao li'
                }
            }

        })
    </script>
</body>
</html>